#include "tile.hpp"
#include "item.hpp"

tile::tile()
{
	texID = 0;
	ID = 0;
	HP = 0;
}

bool tile::isVoid()
{
	// temporary method until I work out a more sensible way
	if( texID == 0 )
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

// possible that with sensible room management that this becomes redundant
bool tile::isPath()
{
	if( texID == 1 || texID == 0 )
	{
		// should check for doors too
		return(false);
	}
	else
	{
		return(true);
	}
}

bool tile::isRoom()
{
	// should maintain a list of which tiles are pathable
	if( texID == 1 || texID == 0 )
	{
		return(false);
	}
	else
	{
		return(true);
	}
}

// stores tile information as a string
std::string tile::toString()
{
	std::stringstream stream;
	stream << ID;

	if( ID != 0 )
		stream << " " << texID << " " << HP;

	return(stream.str());
}

// retrieves tile information from a string generated by tile::toString()
void tile::fromString(const std::string instring)
{
	std::stringstream stream(instring, std::ios_base::in);
	stream >> ID;

	if( ID != 0 )
	{
		stream >> texID >> HP;
	}
	else
	{
		texID = 0;
		HP = 0;
	}
}
